package com.qf.controller;

import com.alibaba.fastjson.JSON;
import com.qf.pojo.Type;
import com.qf.service.TypeService;
import com.qf.service.impl.TypeServiceImpl;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@WebServlet("/type")
public class TypeController extends BaseServlet {
    public String findAllType(HttpServletRequest request, HttpServletResponse response){
        TypeService typeService=new TypeServiceImpl();
        List<Type> list= typeService.findAllType();
        request.setAttribute("goodsTypeList",list);
        return "forward:/admin/showGoodsType.jsp";

    }
    public void findAll(HttpServletRequest request, HttpServletResponse response)throws Exception{
        TypeService typeService=new TypeServiceImpl();
        List<Type> list= typeService.findAllType();
        String jsonStr = JSON.toJSONString(list);
        response.getWriter().println(jsonStr);

    }
}
